﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Id3Lib;
using Mp3Lib;


namespace MyMediaPlayerV2
{
    public class Music : Media
    {
        public String Artist { get; private set; }
        public String Album { get; private set; }
        public String Genre { get; private set; }
        public String Title { get; private set; }
        public String Year { get; private set; }
        public String Duration { get; private set; }

        public Music(String uri)
            : base(uri)
        {
            if (Type == ".mp3")
            {
                Mp3File file = new Mp3File(uri);
                Album = file.TagHandler.Album;
                Artist = file.TagHandler.Artist;
                Genre = findGenre(file.TagHandler.Genre);
                Title = file.TagHandler.Title;
                Year = file.TagHandler.Year;
                TimeSpan t = new TimeSpan(0, 0, 0, Convert.ToInt32(file.Audio.Duration));
                Duration = t.ToString("c");
            }
        }

        private String findGenre(String code)
        {
            if (code == "(10)")
                return ("New Age");
            else if (code == "(80)Folk")
                return ("Folk");
            return ("Unknown");
        }

    }
}
